import org.opencv.core.Core;
import org.opencv.core.Mat;
import org.opencv.highgui.HighGui;
import org.opencv.imgcodecs.Imgcodecs;
import org.opencv.imgproc.Imgproc;
/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86185
 * Date: 2023-04-06
 * Time: 19:53
 */
public class ReadFile {
    public static void main(String[] args) {
        System.loadLibrary(Core.NATIVE_LIBRARY_NAME);//调用opencv库文件
//        Mat src = Imgcodecs.imread("lena.JPG");//读取jpg文件到src中（Mat类）
//        HighGui.imshow("lena",src);//在屏幕上显示图像
//        HighGui.waitKey(0);//等待xms，0表示等待任意键退出
//        Mat mat = Imgcodecs.imread("lena.JPG", Imgcodecs.IMREAD_GRAYSCALE);
        //Imgcodecs.imwrite("lena_gray.JPG", mat);
        Mat src = Imgcodecs.imread("lena.JPG");
        Mat dstImage = new Mat();
        Imgproc.cvtColor(src, dstImage, Imgproc.COLOR_BGR2GRAY,0);
        Imgcodecs.imwrite("lena.JPG", dstImage);
        System.out.println("ok");
    }
}
